import Vue from "vue"
import Vuex from "vuex"
import router from "@/router"
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    //  用户状态 id token
    user: JSON.parse(window.localStorage.getItem("user") || "null"), // 当前登陆
    backlog: [
      "登陆重定向",
      "分配资源",
      "富文本编辑器 上传图片",
      "管理课程ID是固定的需要更改"
    ],
    breadcrumb: "",
    asideHeight: ""
  },
  mutations: {
    // 保存信息
    setUser (state, payload) {
      state.user = JSON.parse(payload)
      window.localStorage.setItem("user", payload)
      router.push("/")
    },
    delUser (state) {
      state.user = null
    },
    setBreadcrumb (state, payload) {
      state.breadcrumb = payload
    },
    setAsideHeight (state, payload) {
      state.asideHeight = payload
    }
  },
  actions: {},
  modules: {}
})
